package com.anda.logistics.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.json.annotations.JSON;

import com.anda.logistics.service.SystemCodeService;
import com.anda.logistics.util.JsonRegionObj;
import com.anda.logistics.vo.JsonReturnVo;

@ParentPackage("json-default")
public class SystemCodeJsonAction extends AndaBaseAction {
	private static final long serialVersionUID = 2661151566635381087L;
	private SystemCodeService systemCodeService;
	private List<String> list;
	private String status="OK";
	private JsonRegionObj json;
	private JsonReturnVo jsonReturnVo;
	
	@Action(value="/manager/system-code-name-json"
			,results=@Result(type="json",name="json",params={"contentType","text/html","enableGZIP","true","noCache","true","excludeNullProperties","true"})
	)
	public String codeNameJson(){
		list = this.systemCodeService.getAllCodeNames();
		return "json";
	}
	
	@Action(value="/manager/system/region-code-json3"
			,results=@Result(type="json",name=SUCCESS,params={"root","json","contentType","text/html","enableGZIP","true","noCache","true","excludeNullProperties","true"})
	)
	public String getRegionJson3(){
		json = systemCodeService.getRegionJsonObj();
		return SUCCESS;
	}
	
	@Action(value="/manager/system/code-json"
		,results=@Result(type="json",name=SUCCESS,params={"root","jsonReturnVo","contentType","text/html","enableGZIP","true","noCache","true","excludeNullProperties","true"})
	)
	public String getSystemCodeJson(){
		jsonReturnVo = systemCodeService.getJsonObj();
		return SUCCESS;
	}
	
	@Action(value="/manager/system/google-region-json"
		,results=@Result(type="json",name=SUCCESS,params={"root","jsonReturnVo","contentType","text/html","enableGZIP","true","noCache","true","excludeNullProperties","true"})
	)
	public String getGoogleRegionJson(){
		jsonReturnVo = systemCodeService.getGoogleRegionJson();
		return SUCCESS;
	}
			
	
	@JSON(name="codeNames")
	public List<String> getList() {
		return list;
	}
	public void setList(List<String> list) {
		this.list = list;
	}
	
	public JsonReturnVo getJsonReturnVo() {
		return jsonReturnVo;
	}

	public void setJsonReturnVo(JsonReturnVo jsonReturnVo) {
		this.jsonReturnVo = jsonReturnVo;
	}

	@JSON(serialize=false)
	public SystemCodeService getSystemCodeService() {
		return systemCodeService;
	}
	@Resource
	public void setSystemCodeService(SystemCodeService systemCodeService) {
		this.systemCodeService = systemCodeService;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public JsonRegionObj getJson() {
		return json;
	}

	public void setJson(JsonRegionObj json) {
		this.json = json;
	}
	
}
